package dao.impl;

import dao.BaseDao;
import dao.dishDao;
import prjo.dish;
import prjo.dishMeg;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;


/**
 * @author shkstart
 * @creat 16:29 2022/6/3
 */

public class dishImpl extends BaseDao implements dishDao {


    @Override
    public ArrayList<dish> showDish(Connection conn) {
        String sql = "select * from dish";
        ArrayList<dish> forList = getForList(conn, dish.class, sql);
        return forList;
    }

    @Override
    public int value(Connection conn, dishMeg dishMeg) {
        String sql = "select sumPrice from name = ?";
        int num = dishMeg.getNum();
        int price = (Integer) getValue(conn, sql, dishMeg.getDish().getName());
        return num * price;
    }

    @Override
    public <T> T select(Connection conn, Class<T> clazz, int id) {
        String sql = "select * from dish where id = ?";
        return getInstance(conn, clazz, sql, id);
    }
}
